import cv2
import numpy as np

# 读取图片
img = cv2.imread('/card.png')
_, thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
# 创建一个结构化元素，用于定义腐蚀的形状和大小
# kernel = np.ones((3, 3), np.uint8)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
# 对图像进行腐蚀操作
eroded_image = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel)

# 显示结果
cv2.imshow('Original', thresh)
cv2.imshow('Eroded', eroded_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
